﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Utility.Model;
using Utility;
using Utility.Json;
using System.Text;

namespace MsgCenter.Web.Handlers
{
    /// <summary>
    /// Handler_UserAuth 的摘要说明
    /// </summary>
    public class Handler_UserAuth : BaseUI.BaseHandler
    {
        /// <summary>
        /// 获取GirdList的操作权限
        /// </summary>
        public void GetAuthOperate()
        {
            List<Sys_Operate> list;
            string strResult = string.Empty;
            string strRequestID = ParamsOfRequest.Request("ModuleID").ToLower();
            if (strRequestID.Length > 0)
            {
                Dictionary<string, List<Sys_Operate>> DicList = base.UserInfo.UserOperate;
                if (DicList.ContainsKey(strRequestID))
                {
                    list = DicList[strRequestID];
                }
                else
                {
                    list = new List<Sys_Operate>();
                }
            }
            else
            {
                list = new List<Sys_Operate>();
            }
            strResult = JsonHelper.ObjectToJson(list);
            base.Response.Write(strResult);
        }
        /// <summary>
        /// 获取没有GridList的操作权限
        /// </summary>
        public void GetAuthOperateMax()
        {
            StringBuilder strBuild = new StringBuilder();
            string strRequestID = ParamsOfRequest.Request("ModuleID").ToLower();
            if (strRequestID.Length > 0)
            {
                Dictionary<string, List<Sys_Operate>> DicList = base.UserInfo.UserOperate;
                List<Sys_Operate> list = DicList[strRequestID];
                string strCssGrid = string.Empty;
                foreach (Sys_Operate model in list)
                {
                    strCssGrid = model.CssCssGrid.TrimStart(' ');
                    strCssGrid = strCssGrid.Split(' ')[0];
                    strBuild.Append("<a id='" + model.OperateValue + "' href='#' onclick='" + model.FunOption + "()' class='" + model.CssCss + "'><i class='" + strCssGrid + " bigger-160'></i>" + model.OperateName + "</a>  ");
                }
            }
            base.Response.Write(strBuild.ToString());
        }
    }
}